/**
 * @author YinHang
 */
;(function () {
	function CalendarCore() {
		this.curDay = new Date();
	};
	
	var monthInfo = {
				1: {
					maxMonth: true
				},
				2: {
					maxMonth: null
				},
				3: {
					maxMonth: true
				},
				4: {
					maxMonth: false
				},
				5: {
					maxMonth: true
				},
				6: {
					maxMonth: false
				},
				7: {
					maxMonth: true
				},
				8: {
					maxMonth: true
				},
				9: {
					maxMonth: false
				},
				10: {
					maxMonth: true
				},
				11: {
					maxMonth: false
				},
				12: {
					maxMonth: true
				}
			};
	
	var Prototype = CalendarCore.prototype;
	
	Prototype.getYear = function () {
		return this.curDay.getFullYear();
	};
	
	Prototype.getMonth = function () {
		return this.curDay.getMonth() + 1;
	};
	
	Prototype.getDate = function () {
		return this.curDay.getDate()
	};
	
	Prototype.getDay = function () {
		return this.curDay.getDay();
	};
	
	Prototype.isLeap = function () {
		return this.getYear() % 100 == 0 ? this.getYear() % 400 == 0 : this.getYear() % 4 == 0;
	};
	
	Prototype.getMaxDayInMonth = function () {
		var maxMonth = monthInfo[this.getMonth()].maxMonth;
		return maxMonth == true ? 31 : ( maxMonth == false ? 30 : ( this.isLeap() ? 29 : 28 ) );
	};
	
	Prototype.getStartDay = function() {
		return 7 - ( ( this.getDate() - this.getDay() ) % 7 ) + 1;
	};
	
	Prototype.setYear = function (year) {
		this.curDay.setFullYear(year);
	};
	
	Prototype.setMonth = function (month) {
		this.curDay.setMonth(month - 1);
	};
	
	Prototype.setDay = function (day) {
		this.curDay.setDay(day);
	};
	
	Prototype.setDate= function (date) {
		this.curDay.setDate(date);
	};
	
	Prototype.setDatePrototype = function (date) {
		this.curDay = date;
	};
	
	Prototype.set = function (year, month, date) {
		this.setYear(year);
		this.setMonth(month);
		this.setDate(date);
	};
	
	window.CalendarCore = CalendarCore;
	
})();